import React, { useEffect } from 'react';

type IAddParam = (x: number,y: number) => number;

type IName =(firstName: string, lastName?: string) => string;

type IRest = (firstName: string, ...rest: string[]) => string;

const Functions = () => {

    const add: IAddParam = (x: number, y: number) : number => {
        return x + y
    }

    const buildName: IName = (firstName: string, lastName = 'KiKi') => {
        if(lastName){
            return firstName + ' ' + lastName;
        }else {
            return firstName
        }
    }

    const restBuildName: IRest = (firstName: string, ...restName: string[]) => {
        return firstName + ' ' + restName.join(' ')
    }

    useEffect(() => {
        console.log(add(1, 2))
        console.log(buildName('a'))
        console.log(restBuildName('a', 'b', 'c', 'd', 'e'))
    }, [])
    return <div>functions</div>
}

export default Functions;
